import { request, config } from 'utils'
import axios from 'axios'
import * as commonService from "utils/services";

const { api } = config
const { products, distributor, dashboard, recommend } = api

export async function query(queryParam) {
  const url = `${products}/list4All`
  return request({ url: url, method: 'post', data: queryParam })
}
export async function queryTypeList() {
  const url = `${products}/classify/list`
  return request({ url: url, method: 'get', data: {} })
}
export async function linkedStoreList({ id }) {
  const url = `${products}/linked/commodity/${id}`
  return request({ url: url, method: 'get', data: {} })
}
export async function materialList({ id }) {
  const url = `${products}/commodity/${id}/material`
  return request({ url: url, method: 'get', data: {} })
}
export async function queryAllStoreList() {
  const url = `${dashboard}`
  return request({ url: url, method: 'get', data: {} })
}
export async function queryStoreList({ queryParam }) {
  const url = `${distributor}/list`
  return request({ url: url, method: 'post', data: queryParam })
}
export async function link(queryParam) {
  const url = `${products}/link`
  return request({ url: url, method: 'post', data: queryParam })
}
export async function alllink({linkedStatus, distributorId}) {
  const url = `${products}/all/${linkedStatus}/${distributorId}`
  return request({ url: url, method: 'get', data: {} })
}

export async function library(params) {
  const url = `${products}/store/add  `
  return request({ url: url, method: 'POST', data: params })
}
export async function allList(params = {}) {
  const url = `${products}/store/all/list`
  return request({ url: url, method: 'GET' });
}
export async function assignStore(params = {}) {
  const url = `${products}/distributor/${params.distributorId}/assign/${params.commodityStoreId}`
  return request({ url: url, method: 'POST' });
}
export async function queryRecommendProduct(queryParam) {
  const url = `${recommend}/list`
  return request({ url: url, method: 'post', data: queryParam })
}
export async function doRecommend(queryParam) {
  const url = `${recommend}/add`
  return request({url: url, method: 'post', data: queryParam})
}
export async function delRecommend(queryParam) {
  const url = `${recommend}/delete`
  return request({url: url, method: 'post', data: queryParam})
}
export async function updateRecommend(queryParam) {
  const url = `${recommend}/sort`
  return request({url: url, method: 'post', data: queryParam})
}
